'use strict';
import {User} from "../user/User";

export class UserManager{

    private static _instance:UserManager=null;

    private _user:User;
    constructor(){
        this._user = new User();
        if(null != UserManager._instance){
            throw new Error('UserManger->Error:单例模式');
        }
    }
    destroy(){
        UserManager._instance = null;
    }

    static getInstance(){
        if(null == UserManager._instance){
            UserManager._instance = new UserManager();
        }
        return UserManager._instance;
    }
    get user(): User {
        return this._user;
    }

    set user(value: User) {
        this._user = value;
    }
    getUserInfo(data) {
        UserManager.getInstance().user.postId = data.GangWeiBH;
        UserManager.getInstance().user.userId = data.YongHuBH;
        UserManager.getInstance().user.branchId = data.BuMenBH;
        UserManager.getInstance().user.branchName = data.buMenMC;
        UserManager.getInstance().user.code = data.Code;
        UserManager.getInstance().user.unitId = data.DanWeiBH;
        UserManager.getInstance().user.unitName = data.DanWeiMC;
        UserManager.getInstance().user.userBranch = data.YongHuDW;
        UserManager.getInstance().user.userName = data.XingMing;
        UserManager.getInstance().user.loginName = data.DengLuM;
        UserManager.getInstance().user.year = data.NianDu;

    }

}